package com.yzg.sign.project.controller;

import com.yzg.sign.project.common.Result;
import com.yzg.sign.project.domain.SysUser;
import com.yzg.sign.project.request.UserAddAndEditRequest;
import com.yzg.sign.project.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/user")
@Api(value = "/api/user" ,tags = {"用户管理"})
public class UserController
{

    @Autowired
    private SysUserService userService;


    @RequestMapping(value = "/saveOrUpdate",method = RequestMethod.POST)
    @ApiOperation("用户添加修改")
    public Result<String> saveOrUpdate(@RequestBody UserAddAndEditRequest request)
    {
         return userService.saveOrUpdate(request);
    }




    @RequestMapping(value = "/getUserPage",method = RequestMethod.POST)
    @ApiOperation("查询用户列表(分页) 搜索条件:userName,phone")
   public Result<Page<SysUser>> getUserPage(@RequestBody Map<String,String> params)
   {
       return userService.getUserPage(params);
   }


   @RequestMapping(value = "/delete/{id}",method = RequestMethod.DELETE)
   @ApiOperation("删除用户")
   public  Result<String> delete(@PathVariable("id")  Integer id)
   {
       return  userService.delete(id);
   }









}
